﻿using System;
using System.Collections.Generic;
using Rodunu.Movies.Services.Models.Netflix.Attributes;
using Rodunu.Movies.Services.Models.Netflix.Enums;

namespace Rodunu.Movies.Services.Models.Netflix
{
    public class FormatAvailability
    {
        public DateTime? Start { get; set; }

        public DateTime? End { get; set; }

        [XPath("/availability/@available_from")]
        public long AvailableFrom
        {
            set
            {
                Start = new DateTime(1970, 1, 1).AddSeconds(value);
            }
        }

        [XPath("/availability/@available_until")]
        public long AvailableUntil
        {
            set
            {
                End = new DateTime(1970, 1, 1).AddSeconds(value);
            }
        }

        [XPath("/availability/category[@scheme='http://api.netflix.com/categories/title_formats']/@term")]
        public Format Format { get; set; }
    }

    public class FormatAvailabilityList : List<FormatAvailability>
    {
        [XPath("/delivery_formats/availability")]
        public List<FormatAvailability> Items
        {
            get { return this; }
        }
    }
}